//
//  Advertiser.h
//  PANBLEPeripherialDemo
//
//  Created by 佳文 on 2018/9/26.
//  Copyright © 2018年 Panchip. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import <ReactiveObjC/ReactiveObjC.h>

#define ADDRESS_LENGTH          5
#define ADV_EXHEADER_LENGTH     13
#define PAYLOAD_MAX_LENGTH      16

@interface HLEAdvertiser : NSObject<CBPeripheralManagerDelegate>

/// 蓝牙外设管理类
@property (strong, nonatomic) CBPeripheralManager* peripheralManager;

@property(nonatomic, strong) RACSubject *advertiserSubject;

/// 单例
+ (instancetype)sharedInstance;

/// 开始广播
- (void)start;

/// 停止广播
- (void)stop;

/// 是否正在广播
- (BOOL)isAdvertising;

/// 设置UUID
/// @param address 地址
/// @param addrLength 地址长度
/// @param payload 目标指令
/// @param payloadLength 目标指令的长度
- (void)setAddress:(Byte *)address ofLength:(int)addrLength andPayload:(Byte *)payload ofLength:(int)payloadLength;

- (void)setPayload:(unsigned char *)payload;

/// 得到广播的长度
/// @param advPayload 广播的数据
- (int)getAdvPayload:(Byte *)advPayload;

/// 蓝牙是否开启
- (BOOL)isBluetoothEnabled;


@end
